﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Rison.BusinessFacade.Helper;
using Rison.Web.Common;
using Rison.BusinessFacade.Common;
using Rison.BusinessFacade.Facade.NRBZ;
using Rison.BusinessFacade.Entity.ZP;
using Rison.BusinessFacade.Facade.ZP;

namespace Rison.Web.NRBZ
{
    public class XWFBPage : PageBase
    {
       

        public virtual string departid
        {
            get
            {
                if (!string.IsNullOrEmpty(Request.QueryString["DepartID"]) && CurrentLoginedUser.UserId != "")
                {
                    return Request.QueryString["DepartID"].ToString();
                }
                return "";
            }
        }

        public virtual string year
        {
            get { return string.IsNullOrEmpty(Request.QueryString["year"]) ? System.DateTime.Today.Year.ToString() : Request.QueryString["year"]; }
        }

        public virtual string userid
        {
            get { return CurrentLoginedUser.UserId; }
        }

        public virtual string id
        {
            get { return "0"; }
        }

        public virtual void btnBack_Click(object sender, EventArgs e)
        {
            Response.Redirect("../ZP/SelfExaminationView.aspx?DepartID=" + departid);
        }

        public virtual DataRow RetriveNrbz()
        {
            NrbzFacade facade = new NrbzFacade();
            DataRow dr = facade.GetInformation(departid, year);
            return dr;
        }

        public virtual void LoadInformation()
        {
        }

        public virtual long SaveInformation()
        {
            return 0;
        }

        #region "历史表更新"

        public string HistorySave(string id)
        {
            HistoryExam hisexam = new HistoryExam();
            HistoryExamFacade facade = new HistoryExamFacade();
            hisexam.ID = System.Guid.NewGuid().ToString();
            hisexam.ExamID = id;
            hisexam.Type = ExamType.网站测评指标自查.ToString();
            hisexam.Year = year;
            hisexam.DepartID = departid;
            hisexam.ModifiedID = this.userid;
            hisexam.ModifiedDate = System.DateTime.Now.ToString();

            int returnValue = facade.InsertHistory(hisexam);

            if (returnValue < 0)
                return "更新历史表报错！";

            return "";

        }
        #endregion

    }
}
